/**
 * @file DBMgr.hpp
 * @author Derek Liu (yjkhtddx@sina.com)
 * @brief 数据库管理器
 * @version 0.0.1
 * @date 2020-07-18
 * 
 * @coryright Copyright Sci-Tech Laboratories (c) 2020
 * 
 */
#pragma once
#include "STL_Mutex.hpp"
#include <map>
#include <string>

class DBMgr
{
public:
    enum TaskStatus{
        NEW,
        WORK
    };

    typedef struct Device_t
    {
        std::string username = "";
        std::string host = "0.0.0.0";
        uint16_t port = 0;
    } Device;

private:
    DBMgr(/* args */);
    ~DBMgr();

public:
    static DBMgr *instance();

public: //Device
    int addDevice(DBMgr::Device info);
    void delDevice(int deviceId);
    void setDevice(int deviceId, DBMgr::Device info);
    DBMgr::Device getDevice(int deviceId);
    std::map<int, DBMgr::Device> getDeviceList();

public: //Task
    void addTask(int deviceId);
    void setTask(int deviceId,DBMgr::TaskStatus status);
    void delTask(int deviceId);
    std::map<int, DBMgr::TaskStatus> getTaskList();
private:
    static int s_id;

private:
    std::map<int, DBMgr::TaskStatus> m_task;
    std::map<int, DBMgr::Device> m_list;
    stl::Mutex m_mtx;
};
/*
INVITE sip:41010200001310000001@10.0.0.47:5060 SIP/2.0
Via: SIP/2.0/UDP 172.20.0.1:15060;rport;branch=z9hG4bK831558840
From: <sip:34020000002000000001@3402000000>;tag=937558840
To: <sip:41010200001310000001@10.0.0.47:5060>
Call-ID: 997558736
CSeq: 59 INVITE
Content-Type: APPLICATION/SDP
Contact: <sip:34020000002000000001@172.20.0.1:15060>
Max-Forwards: 70
User-Agent: LiveGBS v200714
Subject: 41010200001310000001:0102000001,34020000002020000001:0
Content-Length: 214

v=0
o=34020000002000000001 0 0 IN IP4 10.0.0.42
s=Play
c=IN IP4 10.0.0.42
t=0 0
m=video 30016 RTP/AVP 96 97 98
a=recvonly
a=rtpmap:96 PS/90000
a=rtpmap:97 MPEG4/90000
a=rtpmap:98 H264/90000
y=0102000001
*/